<!DOCTYPE html>
<html lang="en">
<head>
  <meta charset="UTF-8">
  <meta http-equiv="pragma" content="no-cache">
  <meta http-equiv="Cache-Control" content="no-cache, must-revalidate">
  <meta http-equiv="expires" content="Wed, 26 Feb 1997 08:21:57 GMT">
  <meta http-equiv="expires" content="0">
  <meta name="viewport" content="width=device-width, user-scalable=no, initial-scale=1.0, maximum-scale=1.0, minimum-scale=1.0">
  <title>心猜详情</title>
  <link rel="stylesheet" type="text/css" href="css/style.css">
  <script type="text/javascript" src="js/fontSize.js"></script>
  <script type="text/javascript" src="js/zepto.min.js"></script>
  <link rel="stylesheet" type="text/css" href="css/swiper.min.css">
  <script type="text/javascript" src="js/vue.js"></script>
  <script type="text/javascript" src="js/layer/layer.js"></script>
  <script type="text/javascript" src="js/jweixin-1.2.0.js"></script>
  <script type="text/javascript" src="js/swiper.min.js"></script>
  <script type="text/javascript" src="js/config.js?v=3"></script>
  <link rel="stylesheet" type="text/css" href="css/detail.css?v=4">
    <link rel="stylesheet" type="text/css" href=" https://at.alicdn.com/t/font_474420_2hkgctv5pzni2j4i.css">
  <style type="text/css">
    .go_test{height: 1.64rem;background: #fff;overflow: hidden;margin: .28rem 0;}
    .test_div{width: 7rem;height: 1.14rem;background: #f0f0f0;border-radius: .1rem;line-height: 1.14rem;margin:.28rem auto 0;}
    .testImg{height: 1.14rem; }
    .test_div .fr{font-size: .3rem;color: #333333;margin-right: .3rem;}
    .test_div .fr img{margin-left: .22rem;width: .4rem;position: relative;top: 0.06rem;}
    .test_result_div{background: url(img/p_65.png) no-repeat; width: 5.43rem;height: 2.25rem;margin:0 auto;background-size: 100% 100%;position: relative;overflow: hidden;}
    .test_result{background: #fff;margin: .28rem 0;padding: .3rem 0 .4rem 0;position: relative;}
    .item_left{float: left;width: 2.29rem;margin-left: .2rem}
    .item_right{float: right;width: 2.29rem;margin-right: .2rem;}
    .test_result_div li:first-child{font-size: .3rem;color: #fb597b;text-align: center;margin-top: .57rem;}
    .test_result_div li:last-child{font-size: .36rem;color: #fb597b;font-weight: bold;text-align: center;margin-top: .15rem;}
    .review{color: #0081d3;font-size: .28rem;position: absolute;bottom: .57rem;right: 1.1rem;text-decoration:none;  border-bottom:1px solid #0081d3;}
    .fixedTop{width: 1.1rem;position: fixed;top: 0;left: .5rem;z-index: 3;}
    

    .optionA_percent{height: 1.12rem;width:5.8rem; position: relative;float: left;}
    .optionA_percent .percent{height: 1.12rem;background: #f8a247;border-top-right-radius: .1rem;border-bottom-right-radius: .1rem;border-left: 1px solid #fff;line-height: 1.12rem;color: #fff;text-indent: .27rem;font-size: .3rem;}
    .optionA_percent .percent.selected{background: #f8dd47;}
    .optionA_percent span{color: #666666;font-size: .3rem;position: absolute;right: .4rem;height: 1.12rem;line-height: 1.12rem;z-index: 3;top: 0;}
    .optionA_percent .baifen{line-height: 1.12rem;color: #fff;text-indent: .27rem;font-size: .3rem;position: absolute;top: 0;left: 0;}
    .optionA_percent .baifen.white{color:#666666;}
    /*.selects{display: none;}*/
    .selected .percent{background: #f8dd47;}
  /*  .selected .optionA_left{display: none;}
     .selected .optionA_left.selects{display: block;}
*/
    </style>


</head>
<body>
  
<div id="app">
     <img src="img/p_55.png" alt="" class="ruleimg" @click="toggleRule">
     <img src="img/p_40.png" alt="" class="fixedTop">
      

    
    <!-- 输入观点弹窗 -->
    <div class="mask_layer" v-show="viewFlag">
        <div class="mask_model" @click="toggleView" id="dis_scroll"></div>
        <div class="views_content">
            <textarea id="view" placeholder="请输入您的观点..." v-model.trim="commentContent"></textarea> 
            <button type="button" @click="addComtent">确定</button>
        </div>
    </div>
    <!-- 输入观点弹窗 end-->

    <!-- 中奖弹窗 -->
    <div class="rule_mask" v-show="prizeStatus">
      <div class="rule_model" @click="togglePrize"></div>
      <div class="prize_content">
          <div class="prize_title">{{resObj.award}}</div>
          <div class="tel_input">
              <span>手机号</span>
              <input type="number" placeholder="请输入手机号" v-model.trim="tel" />        
          </div>
          <div class="tel_input">
              <span @click="sendMes">{{verification}}</span>
              <input type="number" placeholder="请输入验证码" v-model.trim="code" />        
          </div>
          <button class="sendcontact" type="button" @click="saveTel">发送联系方式</button>
          <div class="prize_tip">
             <span>*中奖后10个工作日内，心猜的工作人员会跟您联系，请耐心等待~</span>                 
          </div>
          <img src="img/p_28.png" alt="" class="close_prize"  @click="togglePrize">
      </div>
    </div>
      <!-- 中奖弹窗end -->
   <!-- 未中奖弹窗 -->
      <div class="rule_mask" v-if="loseFlag&&(resObj.answered==1)&&(resObj.can_answer==0)&&(resObj.isEnd==1)&&(resObj.is_winner==0)">
          <div class="rule_model" @click="toggleLose"></div>
          <div class="winning_content">
                <img src="img/p_26.png" alt="" class="lose_img">
                <span class="lose_text">很遗憾，未中奖</span>
                <ul class="lose_ul">
                  <li>详细排名请关注微信公众号：</li>
                  <li>心对APP</li>
                  <li>这里有更多免费竞猜哟！</li>
                </ul>
                <button type="button" class="close_lose" @click="toggleLose">确定</button>
          </div>
      </div>
   <!-- 未中奖弹窗 -->
    <!-- 分享弹窗 -->
    <div class="mask_layer" v-if="shareFlag&&(resObj.answered==1&&resObj.reAnswerCode==2)&&resObj.can_answer==1&&resObj.shareToRefresh==1&&share_able==1">
        <div class="mask_model" @click="toggleShare"></div>
        <img src="img/p_56.png" alt="" class="shareimg"  @click="toggleShare">
    </div>
    <!-- 分享弹窗 -->

    <!-- 点按钮出现分享弹窗 -->
    <div class="mask_layer" v-show="shareFlag1&&share_able==1">
        <div class="mask_model" @click="toggleShare1"></div>
        <img src="img/p_56.png" alt="" class="shareimg"  @click="toggleShare1" v-if="resObj.shareTofresh==1">
        <img src="img/p_73.png" alt="" class="shareimg"  @click="toggleShare1" v-else>
    </div>
    <!-- 分享弹窗 -->

    <!-- 图片弹窗 -->
    <div class="rule_mask" v-if="popFlag&&(resObj.answerImg!='')&&(resObj.answered==1)&&resObj.can_answer==1">
        <div class="pop_content">
          <!-- <img src="img/pop.jpg"   alt="" class="popImg"> -->
           <img :src="resObj.answerImg"   alt="" class="popImg">
           <div class="save">长按图片保存 分享到朋友圈</div>
           <img src="img/p_28.png" alt="" class="closePop" @click="togglePop">
       </div>
    </div>
    <!-- 图片弹窗 -->
    <!-- 规则弹窗 -->
      <div class="rule_mask" v-show="ruleFlag">
           <div class="rule_model"  @click="toggleRule"></div>
           <div class="rule_content">
                <div class="rule_title">
                    <img src="img/p_20.png" alt="" class="rule_img">
                     奖励规则
                    <img src="img/p_20.png" alt="" class="rule_img">
                </div>
                <div class="rule_list_content">
                  <div class="rule_list" v-for="(item,index) in rules">
                    <span>{{index+1}}</span>
                    <div class="rule_detail">{{item.rule}}</div>        
                  </div>
                </div>
                <div class="rule_bottom">- 本活动最终解释权归心猜所有 -</div>

                
                <img src="img/p_21.png" alt="" class="closeImg1"  @click="toggleRule">

           </div>
      </div>
    <!-- 规则弹窗 end -->

  
    <div class="header">     
        <div class="img_div">
          <img :src="resObj.url" class="list_img" /> 
            <span class="time">{{resObj.str}}</span> 
            <div class="icon_prises">
              <!-- 参与 -->
             <img src="img/p_59.png" class="icon_prise" v-if="resObj.before==1" /> 
             <img src="img/p_22.png" class="icon_prise" v-if="resObj.answered==1&&resObj.can_answer==1" /> 
             <img src="img/p_23.png" class="icon_prise" v-if="resObj.before==0&&resObj.can_answer==0" /> 
             
              <!-- 参与 end-->
            </div>    
        </div>
        <div class="title">
            {{resObj.title}}
        </div>
        <div class="content">
           {{resObj.content}}
        </div>
    </div> 
    <div class="options" v-if="resObj.type==0">
        <div class="option" v-for="item in resObj.options">
          <div class="options_content">{{item.content}}:</div>
          <div class="options_input">
              <input :placeholder="item.tip" onpaste="return false;" v-model.trim="item.guess_num" v-if="resObj.reAnswerCode==1" />
              <input :placeholder="item.tip" onpaste="return false;" v-model.trim="item.guess_num"  disabled="true" v-else-if="(resObj.answered==1)||(resObj.can_answer==0)||(resObj.isEnd==1)||(resObj.reAnswerCode==0)" />
              <input :placeholder="item.tip" onpaste="return false;" v-model.trim="item.guess_num" v-else />
              <span>{{item.unit}}</span>        
          </div>
        </div>
        <div class="option" v-for="(item,i) in resObj.selects">
          <div class="options_content options_content1">{{item.title}}:</div>
          <div class="optionA" @click="select(i,j)"  v-for="(value,j) in item.options" v-if="resObj.reAnswerCode==1">
            <div class="optionA_left" v-if="value.selected==false">
               {{value.index}}
            </div>
            <div class="optionA_left selects" v-else>
              <img src="img/p_48.png" alt="">
            </div>
            <div class="optionA_right">
              <span class="text">{{value.content}}</span>
            </div>
          </div>
          <div class="optionA" v-else-if="item.guess_answer||resObj.can_answer==0||resObj.answered==1||resObj.isEnd==1||(resObj.reAnswerCode==0)">
            <div class="optionA_left" v-if="item.guess_answer!=value.index">
               {{value.index}}
            </div>
            <div class="optionA_left selects" v-else>
              <img src="img/p_48.png" alt="">
            </div>
            <div class="optionA_right">
              <span class="text">{{value.content}}</span>
            </div>
          </div>
          <div class="optionA" @click="select(i,j)" v-else>
            <div class="optionA_left" v-if="value.selected==false">
               {{value.index}}
            </div>
            <div class="optionA_left selects" v-else>
              <img src="img/p_48.png" alt="">
            </div>
            <div class="optionA_right">
              <span class="text">{{value.content}}</span>
            </div>
          </div>  
        </div>
        <button type="button" class="confirm1" v-if="resObj.is_winner==1&&cell&&resObj.can_answer==0&&resObj.answered==1&&resObj.isEnd==1">联系方式已发送</button>
        <button type="button" class="confirm1" @click="togglePrize" v-else-if="resObj.is_winner==1&&resObj.can_answer==0&&resObj.answered==1&&resObj.isEnd==1">领取奖品</button>
        <button type="button" class="confirm1" v-else-if="resObj.is_winner==0&&resObj.can_answer==0&&resObj.answered==1&&resObj.isEnd==1">未中奖</button>
        <button type="button" class="confirm1" v-else-if="resObj.can_answer==0&&resObj.answered==0&&resObj.before==1">活动未开始</button>
        <button type="button" class="confirm1" v-else-if="resObj.can_answer==0&&resObj.answered==0">活动已结束</button>
        <button type="button" class="confirm1" v-else-if="resObj.answered==1&&resObj.reAnswerCode==2">已竞猜</button>
        <button type="button" class="confirm1" v-else-if="resObj.reAnswerCode==0">已竞猜</button>
        <button type="button" class="confirm" v-else @click="save">确  定</button>
    </div>
    <div v-if="resObj.type==1">
      <div class="go_test" v-if="resObj.answered==0&&((resObj.can_answer==0)||(resObj.isEnd==1))">
        <div class="test_div" @click="goEnd">
          <img src="img/p_62.png" alt="" class="testImg">
          <div class="fr">
             前去测试
             <img src="img/p_66.png" alt="" class="flImg">
          </div>
        </div>
      </div>
       <div class="go_test" v-else-if="resObj.answered==0">
        <div class="test_div"  @click="goTest">
          <img src="img/p_62.png" alt="" class="testImg">
          <div class="fr">
             前去测试
             <img src="img/p_66.png" alt="" class="flImg">
          </div>
        </div>
      </div>

      <div class="test_result" v-else>
          <div class="test_result_div">
            <ul class="item_left">
              <li>您共答对</li>
              <li v-if="resObj.sub_question_result">{{resObj.sub_question_result.right_count}}题</li>
            </ul>
            <ul class="item_right">
               <li>您的得分</li>
               <li v-if="resObj.sub_question_result">{{resObj.sub_question_result.score}}分</li>
            </ul>
          </div>
          <button type="button" class="confirm1" v-if="resObj.is_winner==1&&cell&&resObj.can_answer==0&&resObj.answered==1&&resObj.isEnd==1">联系方式已发送</button>
          <button type="button" class="confirm1" @click="togglePrize" v-else-if="resObj.is_winner==1&&resObj.can_answer==0&&resObj.answered==1&&resObj.isEnd==1">领取奖品</button>
          <button type="button" class="confirm1" v-else-if="resObj.is_winner==0&&resObj.can_answer==0&&resObj.answered==1&&resObj.isEnd==1">未中奖</button>
          <button type="button" class="confirm1" v-else-if="resObj.can_answer==0&&resObj.answered==0&&resObj.before==1">活动未开始</button>
          <button type="button" class="confirm1" v-else-if="resObj.can_answer==0&&resObj.answered==0">活动已结束</button>
          <button type="button" class="confirm1" v-else-if="resObj.answered==1">已竞猜</button>
          <button type="button" class="confirm" v-else @click="save">确  定</button>
          <span class="review" @click="goNext" v-if="resObj.can_answer==0&&resObj.before==0&&resObj.sub_question_result&&resObj.sub_question_result.wrong_count!=0">错题回顾</span>
      </div>
    </div> 
    <div v-if="resObj.type==2">
      <div class="go_test" v-if="resObj.answered==0&&((resObj.can_answer==0)||(resObj.isEnd==1))">
        <div class="test_div" @click="goEnd">
          <img src="img/p_62.png" alt="" class="testImg">
          <div class="fr">
             前去测试
             <img src="img/p_66.png" alt="" class="flImg">
          </div>
        </div>
      </div>
       <div class="go_test" v-else-if="resObj.answered==0">
        <div class="test_div"  @click="goTest">
          <img src="img/p_62.png" alt="" class="testImg">
          <div class="fr">
             前去测试
             <img src="img/p_66.png" alt="" class="flImg">
          </div>
        </div>
      </div>

      <div class="test_result" v-else>
          <div class="test_result_div">
            <ul class="item_left">
              <li>您共答对</li>
              <li v-if="resObj.sub_question_result">{{resObj.sub_question_result.right_count}}题</li>
            </ul>
            <ul class="item_right">
               <li>您的得分</li>
               <li v-if="resObj.sub_question_result">{{resObj.sub_question_result.score}}分</li>
            </ul>
          </div>
          <button type="button" class="confirm1" v-if="resObj.is_winner==1&&cell&&resObj.can_answer==0&&resObj.answered==1&&resObj.isEnd==1">联系方式已发送</button>
          <button type="button" class="confirm1" @click="togglePrize" v-else-if="resObj.is_winner==1&&resObj.can_answer==0&&resObj.answered==1&&resObj.isEnd==1">领取奖品</button>
          <button type="button" class="confirm1" v-else-if="resObj.is_winner==0&&resObj.can_answer==0&&resObj.answered==1&&resObj.isEnd==1">未中奖</button>
          <button type="button" class="confirm1" v-else-if="resObj.can_answer==0&&resObj.answered==0&&resObj.before==1">活动未开始</button>
          <button type="button" class="confirm1" v-else-if="resObj.can_answer==0&&resObj.answered==0">活动已结束</button>
          <button type="button" class="confirm" v-else-if="resObj.answered==1" @click="goTest">重答一次</button>
          <button type="button" class="confirm" v-else @click="save">确  定</button>
          <span class="review" @click="goNext" v-if="resObj.can_answer==0&&resObj.before==0&&resObj.sub_question_result&&resObj.sub_question_result.wrong_count!=0">错题回顾</span>
      </div>
    </div> 
    <div v-if="resObj.type==3">
      <div class="options">
          <div v-if="resObj.sub_question_summary">
            <div class="option" v-for="(item,i) in resObj.sub_question_summary">
                <div class="options_content options_content1">{{item.content}}:</div>
                <div class="optionA" v-for="(value,j) in item.options">
                  <div class="optionA_left" v-if="value.id!=item.oid">
                     {{value.idx}}
                  </div>
                  <div class="optionA_left selects" v-else>
                    <img src="img/p_48.png" alt="">
                  </div>
                  <div class="optionA_percent" :class="value.id==item.oid?'selected':''">
                    <div class="percent" :style="'width:'+value.percent+'%;'"></div>
                    <div class="baifen" :class="value.percent==0?'white':''">{{value.percent}}%</div>
                    <span>{{value.count}}选择</span>
                  </div>
                </div>
            </div>
          </div>
          <div v-else-if="resObj.answered==0&&((resObj.can_answer==0)||(resObj.isEnd==1))">
            <div class="option" v-for="(item,i) in questions">
                <div class="options_content options_content1">{{item.content}}:</div>
                <div class="optionA" v-for="(value,j) in item.options">
                  <div class="optionA_left" v-if="value.selected==false">
                   {{value.idx}}
                  </div>
                  <div class="optionA_left selects" v-else>
                    <img src="img/p_48.png" alt="">
                  </div>
                  <div class="optionA_right">
                    <span class="text">{{value.content}}</span>
                  </div>
                </div>
            </div>
          </div>
          <div  v-else>
          <div class="option" v-for="(item,i) in questions">
              <div class="options_content options_content1">{{item.content}}:</div>
              <div class="optionA" v-for="(value,j) in item.options"  @click="selectQues(i,j)">
                <div class="optionA_left" v-if="value.selected==false">
                 {{value.idx}}
                </div>
                <div class="optionA_left selects" v-else>
                  <img src="img/p_48.png" alt="">
                </div>
                <div class="optionA_right">
                  <span class="text">{{value.content}}</span>
                </div>
              </div>
          </div>
          </div>

          <button type="button" class="confirm1" v-if="resObj.is_winner==1&&cell&&resObj.can_answer==0&&resObj.answered==1&&resObj.isEnd==1">联系方式已发送</button>
          <button type="button" class="confirm1" @click="togglePrize" v-else-if="resObj.is_winner==1&&resObj.can_answer==0&&resObj.answered==1&&resObj.isEnd==1">领取奖品</button>
          <button type="button" class="confirm1" v-else-if="resObj.is_winner==0&&resObj.can_answer==0&&resObj.answered==1&&resObj.isEnd==1">未中奖</button>
          <button type="button" class="confirm1" v-else-if="resObj.can_answer==0&&resObj.answered==0&&resObj.before==1">活动未开始</button>
          <button type="button" class="confirm1" v-else-if="resObj.can_answer==0&&resObj.answered==0">活动已结束</button>
          <button type="button" class="confirm1" v-else-if="resObj.answered==1">已竞猜</button>
          <button type="button" class="confirm" @click="saveAnswer" v-else>确  定</button>
      </div>
    </div>

    <div class="prize" v-if="giftList.length>0">
      <ul>
        <li class="prize_list" v-for="item in giftList">
          <div class="prize_img" @click="previewImage(item.img)">
            <img :src="item.img" alt="">
            <span class="prize_num">{{item.tipInfo}}</span>
          </div>
          <div class="prize_name">
            {{item.name}}
          </div>
          <div class="prize_money">
            {{item.valueInfo}}
          </div>
        </li>
      </ul>
    </div>
    <div class="hezuo" v-if="sponsor.length>0">
      <div class="hezuo_title">合作伙伴</div>
          <ul class="hezuo_ul" v-if="sponsor.length<=4">
            <li v-for="(item,i) in sponsor" @click="previewImage(item.ewm)">
              <div class="hezuo_logo">
                <span></span>
                <img :src="item.logo" alt="">
              </div>
              <div class="logo_name">{{item.name}}</div>
            </li>
          </ul>
          <div class="swiper-container" v-else>
            <div class="swiper-wrapper">
              <div class="swiper-slide" v-for="(value,index) in parseInt(sponsor.length/4)*4<sponsor.length?(parseInt(sponsor.length/4)+1):parseInt(sponsor.length/4)">
                  <ul class="hezuo_ul">
                    <li v-for="(item,i) in sponsor" @click="previewImage(item.ewm)" v-if="i<(value*4)&&i>=((value-1)*4)">
                      <div class="hezuo_logo">
                        <span></span>
                        <img :src="item.logo" alt="">
                      </div>
                      <div class="logo_name">{{item.name}}</div>
                    </li>
                  </ul>
              </div>
            </div>
          </div>
    </div>
    <div class="views" v-if="comment.length>0">
      <div class="views_title">观点</div>
      <ul>
        <li class="views_list borderBottom" v-for="item in comment">
            <img :src="item.headUrl" alt="" class="views_list_photo">
            <div class="views_right">
                <div class="views_time">
                    <ul>
                        <li>{{item.nickname}}</li>
                        <li>{{item.createTime.date.slice(0,10)}}</li>
                    </ul>
                    <span @click="like(item.id)">
                       {{item.thumbsUpCount}}
                      <i class="iconfont icon-dz" v-if="item.isThumbsUp==0"></i>
                      <i class="iconfont icon-dianzan" v-else></i>
                    </span>
                </div>
                <div class="views_info">
                   {{item.content}}
                </div>
            </div>
          
        </li>
      </ul>
      <div class="lookmore" v-if="isend==0" @click="lookmore">查看更多</div>
      <div class="nomore" v-else>没有更多了~</div>
    </div>
    <div class="footer">
       <button type="button" @click="toggleView">发表观点</button>
       <span class="share_btn" @click="toggleShare1"><i class="iconfont icon-fenxiang"></i>分享</span>
    </div>
</div>

    <script type="text/javascript">
      
        var app = new Vue({
            el: '#app',
            data: {
                viewFlag:false,
                ruleFlag:false,
                shareFlag:true,
                shareFlag1:false,
                popFlag:true,
                disabled:false,
                loseFlag:true,
                prizeStatus:false,
                codetimer:null,
                prizeList:[],
                verification:'获取验证码',
                giftList:[],
                rules:[],
                tel:"",
                cell:"",
                code:"",
                sponsor:[],
                info:{},
                id:GetQueryString("id"),     
                unionid:GetQueryString("unionid"), 
                comment:[],
                questions:[],
                from:0,
                isend:0,
                update:false,
                commentContent:"",
                resObj:{
                   options:[],
                   selects:[],
                   type:4
                },
                flag:true,
                num:0,
                share_able:0,
                
                dblClick:false,
                disabled:false,
                index:0
            },
            mounted(){

              showMenu();
              var that=this;
              // document.getElementById("dis_scroll").addEventListener('touchmove', function (event) {
              //   event.preventDefault();
              // });
              var that=this;
              this.getRule();
              this.getSponsor();
              // this.getInfo();
              this.getDetail();
              this.getGiftList();
              this.getComtent(this.from);
              this.loginWx1();

              this.getGroup();
            },
            methods: {
                toggleView:function(){
                    this.viewFlag=!this.viewFlag;
                },
                goBack:function(){
                   window.location.href=document.referrer;
                },
                goEnd:function(){
                   showLayer("活动已结束");
                },
                goNext(){
                   location.href='mistakes.html?id='+this.id+'&unionid='+this.unionid;
                },
                select:function(n,m){
                     for (var j = 0; j < this.resObj.selects[n].options.length; j++) {
                        this.resObj.selects[n].options[j].selected=false;
                     }
                     this.resObj.selects[n].options[m].selected=true;
                     this.resObj.selects=this.resObj.selects.slice();
                },
                selectQues:function(n,m){
                      var that=this;           
                      if(this.dblClick){
                        return;
                      }
                      for (var j = 0; j < this.questions[n].options.length; j++) {
                          this.questions[n].options[j].selected=false;
                      }
                      this.questions[n].options[m].selected=true;
                      this.questions=this.questions.slice(); 
                },
                saveAnswer(){
                  var that=this;
                  if(this.dblClick){
                    return;
                  }
                  var answers=[];
                  for (var i = 0; i < this.questions.length; i++) {
                    var obj={};
                    obj.id=this.questions[i].id;
                    for (var j = 0; j < this.questions[i].options.length; j++) {
                        if(this.questions[i].options[j].selected){
                              obj.oid=this.questions[i].options[j].id;
                        }         
                    }
                    if(obj.oid!=undefined){
                       answers.push(obj);
                    }              
                   
                  }
                  if(that.questions.length>answers.length){
                      showLayer("请选择答案");
                      return; 
                  }
                  this.dblClick=true;
                  ajaxFun("POST","/guess/sub_questions_proportion/answer",{
                         qid:this.id,
                         unionid:this.unionid,
                         answers:answers
                      },function(data){
                        var res=data;
                        if(res.code==1){
                          showLayer("竞猜成功");
                          that.getDetail();
                      
                        }else{
                          
                            // showLayer(res.message);
                        }
                       that.dblClick=false;
                   }); 
                },
                getGroup:function(){
                 var that=this;
                   ajaxFun("GET","/guess/sub_questions?qid="+this.id,{
                       // q_id:1
                   },function(data){
                      var res=data;
                      if(res.error==0){
                        for (var i = 0; i < res.questions.length; i++) {
                            for (var j = 0; j < res.questions[i].options.length; j++) {
                              res.questions[i].options[j].selected=false;
                            }
                        }
                        that.questions=res.questions;
                        console.log( that.questions)
                      }else{

                      }
                              
                  }); 
                },
                lookmore:function(){
                  var that=this;
                  if(that.isend==0){
                      that.from=that.from+60;
                      that.getComtent(that.from);  
                    }
                },
                togglePrize(){
                   this.prizeStatus=!this.prizeStatus;  
                },
                toggleLose(){
                  this.loseFlag=!this.loseFlag;  
                },
                goTest(){
                   // localStorage.flag=true;
                  window.location.replace(mainUrl+"/questions.html?id="+this.id+"&unionid="+this.unionid);
                  // window.location.href="rules.html?id="+this.id+"&unionid="+this.unionid; 

                   // setTimeout(function(){
                   // },300);
                            
                },
                saveTel(){
                    var myreg = /^1\d{10}$/;
                    var that=this;
                    if(!myreg.exec(this.tel)){
                        showLayer("请输入正确的手机号");
                        return;
                    }
                    if(this.code==""){
                        showLayer("请输入验证码");
                        return;
                    }
                    ajaxFun("POST","/check_code",{
                       tell: this.tel,
                       code:this.code,
                       unionid:this.unionid
                    },function(data){
                        var res=data;
                        if(res.code==1){
                           showLayer("联系方式发送成功"); 
                           that.togglePrize();
                           that.cell=that.tel;


                        }else{
                           showLayer(res.message);   
                        }
                                
                    });
                },
  
                previewImage:function(url){
                  wx.previewImage({
                      current: url, // 当前显示图片的http链接
                      urls: [url] // 需要预览的图片http链接列表
                  });
                },
                toggleShare:function(){
                    this.shareFlag=!this.shareFlag;
                },
                toggleShare1:function(){
                    this.shareFlag1=!this.shareFlag1;
                },
                toggleRule:function(){
                    this.ruleFlag=!this.ruleFlag;
                },
                togglePop:function(){
                    this.popFlag=!this.popFlag;  
                },
                countDown:function(){
                  var that=this,time=120;
                  if(that.disabled){
                      return;
                  }
                  this.codetimer=setInterval(function(){
                      time--;
                      that.disabled=true; 
                      that.verification="重新发送("+time+")";
                      if(time==0){
                          that.disabled=false;
                          that.verification="获取验证码";
                          time=120;
                          clearInterval(that.codetimer);
                      }
                  }, 1000);
                },
                getPrize:function(){
                  var that=this;
                  ajaxFun("POST","/get_winner_list",{
                     q_id:this.id,
                     unionid:this.unionid
                  },function(data){
                      var res=data;
                      if(res.code==1){
                         that.prizeList=res.data.list;  
                      }else{

                      }
                              
                  });
                  
                },
                getInfo:function(){
                    var that=this;
                    ajaxFun1("POST","/get_guess_info",{
                      
                    },function(data){
                      var res=data;
                        if(res.code==1){
                           that.unionid=res.data.info.unionid; 
                           that.info = res.data.info; 
                          
                           that.loginWx();

                          
                         
                        }else{
                           // showLayer(res.message);
                        }
                              
                    });
                },
                loginWx1:function(){
                    var that=this;
                    ajaxFun("POST","/login_wx",{
                        unionid:this.unionid
                      
                    },function(data){
                        var res=data;
                        if(res.code==1){
                          that.cell=res.data.user_info.cell;
                        }else{
                          // showLayer(res.message);
                        }
                              
                    });
                },
                loginWx:function(){
                    var that=this;
                    ajaxFun("POST","/login_wx",{
                        unionid:this.info.unionid,
                        openid:this.info.openid,
                        sex:this.info.sex,
                        headimgurl:this.info.headimgurl,
                        nickname:this.info.nickname
                      
                    },function(data){
                        var res=data;
                        if(res.code==1){
                            that.getDetail();
                            that.getGiftList();
                            that.getComtent(that.from);

                        }else{
                          showLayer(res.message);
                        }
                              
                    });
                },
                getRule:function(){
                  var that=this;
                  ajaxFun("POST","/get_rule",{
                     q_id:this.id
                  },function(data){
                       var res=data;
                      if(res.code==1){
                         that.rules=res.data.rule;  
                      }else{

                      }
                              
                  });
                },
                like:function(id){
                  var that=this;
                  ajaxFun("POST","/change_thumb_up",{
                     c_id:id,
                     unionid:this.unionid
                  },function(data){
                      var res=data;
                      if(res.code==1){
                        showLayer(res.message);
                        that.getComtent(that.form);
                      }else{
                        showLayer(res.message);
                      }
                              
                  });
                },
                getSponsor:function(){
                  var that=this;
                  ajaxFun("POST","/get_sponsor",{
                     q_id:this.id
                  },function(data){
                      var res=data;
                      if(res.code==1){
                         that.sponsor=res.data.sponsor;  
                         setTimeout(function(){
                          var mySwiper = new Swiper('.swiper-container', {
                            autoplay: 2000

                            // loop:true
                          });

                         },300);
                         
                      }else{

                      }
                              
                  });
                },
                getDetail:function(){
                  var that=this;
                  ajaxFun("POST","/get_question",{
                     q_id:this.id,
                     unionid:this.unionid
                  },function(data){
                      var res=data;
                      if(res.code==1){
                          that.resObj=res.data.question; 
                          that.share_able=res.share_able;
                          var time=getTime(that.resObj.begin_time_date);
                          var time1=getTime(that.resObj.e_time_date);
                          var time2=getTime(that.resObj.expire_date);
                          if(res.now_mic_time<time){
                             var phase=time-res.now_mic_time;
                             that.resObj.str="距离开始："+getDay(phase)+"天"+getHour(phase)+"时"+getMiute(phase)+"分";
                             that.resObj.before=1;
                          }else if(time<res.now_mic_time&&res.now_mic_time<time1){
                              var phase1=time1-res.now_mic_time;
                              that.resObj.str="距离答题结束："+getDay(phase1)+"天"+getHour(phase1)+"时"+getMiute(phase1)+"分";
                              that.resObj.before=0;
                          }else if(res.now_mic_time>time1&&res.now_mic_time<time2){
                              var phase2=time2-res.now_mic_time;
                              that.resObj.str="距离活动结束："+getDay(phase2)+"天"+getHour(phase2)+"时"+getMiute(phase2)+"分";
                              that.resObj.before=0;
                          }else{
                              that.resObj.str="竞猜时间："+that.resObj.begin_time_str+"-"+that.resObj.expire_str;
                              that.resObj.before=0;
                          }
                          for (var i = 0; i < that.resObj.selects.length; i++) {
                               for (var j = 0; j < that.resObj.selects[i].options.length; j++) {
                                   that.resObj.selects[i].options[j].selected=false;
                               }
                          }
                          if(that.resObj.sub_question_summary){
                              for (var k = 0; k < that.resObj.sub_question_summary.length; k++) {
                                  var sum=0,per=0;
                                  for (var n = 0; n < that.resObj.sub_question_summary[k].options.length; n++) {
                                    sum+=parseInt(that.resObj.sub_question_summary[k].options[n].count);       
                                  }
                                  that.resObj.sub_question_summary[k].sum=sum; 
                                  for (var m = 0; m < that.resObj.sub_question_summary[k].options.length; m++) {
                                      var t= that.resObj.sub_question_summary[k].options[m];
                                      t.percent=((parseInt(t.count)/sum).toFixed(2))*100;
                                      if(m<that.resObj.sub_question_summary[k].options.length-1){
                                          per+=t.percent;
                                      }else{
                                        t.percent=100-per;
                                      } 
                                    
                                  }

                              }  

                          }

                          console.log(that.resObj.sub_question_summary)
                          // that.getShare(that.resObj); 
                      }else{
                      }
                              
                  });    
                },
                getGiftList:function(){
                  var that=this;
                  ajaxFun("POST","/get_prize_list",{
                      unionid:this.unionid,
                      q_id:this.id
                  },function(data){
                      var res=data;
                      if(res.code==1){
                        that.giftList=res.data.prize_list;
                      }else{

                      }
                              
                  });
                },
                getShare:function(){
                  var that=this;
                  ajaxFun1("POST","/get_guess_share_config",{
                     q_id:this.id,
                     qqq:encodeURIComponent(window.location.href)
                  },function(data){
                    var res=data;
                    console.log(data)
                     if(res.code==1){
                         var config=res.data.config;
                          wx.config({
                            debug: false, // 开启调试模式,调用的所有api的返回值会在客户端alert出来，若要查看传入的参数，可以在pc端打开，参数信息会通过log打出，仅在pc端时才会打印。
                            appId: config.appId, // 必填，公众号的唯一标识
                            timestamp: config.timestamp, // 必填，生成签名的时间戳
                            nonceStr:  config.nonceStr, // 必填，生成签名的随机串
                            signature: config.signature,// 必填，签名，见附录1
                            jsApiList: ['onMenuShareTimeline', 'onMenuShareAppMessage'] // 必填，需要使用的JS接口列表，所有JS接口列表见附录2
                          });
                          var url=that.resObj.share_info.url+that.unionid;
                          var share=shareUrl+encodeURIComponent(httpUrl+url);
                          console.log(share)
                          // console.log(httpUrl+url)

                          wx.ready(function(){
                            wx.onMenuShareTimeline({
                                title: that.resObj.share_info.title, // 分享标题
                                link:share, // 分享链接，该链接域名或路径必须与当前页面对应的公众号JS安全域名一致
                                imgUrl: that.resObj.share_info.img, // 分享图标
                                success:function(){
                                   that.getCount("share_detail/"+that.id);
                                   if(that.resObj.shareTofresh==1){
                                     that.shareCount(that.unionid);
                                     that.togglePop();
                                   }
                                  
                                  
                                },
                                cancel:function(){

                                }
                            });
                            wx.onMenuShareAppMessage({
                                  title: that.resObj.share_info.title, // 分享标题
                                  desc: that.resObj.share_info.content, // 分享描述
                                  link: share, // 分享链接，该链接域名或路径必须与当前页面对应的公众号JS安全域名一致
                                  imgUrl: that.resObj.share_info.img, // 分享图标
                                  type: 'link', // 分享类型,music、video或link，不填默认为link
                                  dataUrl: '', // 如果type是music或video，则要提供数据链接，默认为空
                                  success: function () { 
                                    that.getCount("share_detail/"+that.id);
                                    if(that.resObj.shareTofresh==1){
                                       that.shareCount(that.unionid);
                                       that.togglePop();
                                    }
                                    
                                      // 用户确认分享后执行的回调函数
                                  },
                                  cancel: function () { 
                                      // 用户取消分享后执行的回调函数
                                  }
                              });
                          
                          });
                     }
                            
                  });
                },
                getCount:function(str){
                  var that=this;
                  ajaxFun("POST","/share_count",{
                      route:str
                  },function(data){
                     
                              
                  });
                },
                shareCount:function(unionid){
                  var that=this;
                  ajaxFun("POST","/share_count",{
                     q_id:this.id,
                     unionid:unionid,
                     route:"share_detail/"+this.id
                  },function(data){
                      var res=data;
                      if(res.code=="success"){
                          that.getDetail();
                      }else{

                      }
                              
                  });
                },
                sendMes:function(){
                    var myreg = /^1\d{10}$/;
                    var that=this;
                    if(!myreg.exec(this.tel)){
                        showLayer("请输入正确的手机号");
                        return;
                    }
                    ajaxFun("POST","/send_sms",{
                       tell: this.tel,
                       unionid:this.unionid
                    },function(data){
                      var res=data;
                      if(res.code==1){
                         showLayer("获取验证码成功"); 
                         that.countDown();
                      }else{
                         showLayer(res.message);    
                      }
                       
                                
                    });
                },
                getComtent:function(from){
                  var that=this;
                  ajaxFun("POST","/get_comment_list",{
                      unionid:this.unionid,
                      q_id:this.id,
                      from:from,
                      length:60
                  },function(data){
                     var res=data;

                      if(res.code==1){
                        if(res.data.list.length<60){
                            that.isend=1;      
                        }
                        that.comment=res.data.list;
                        // for (var i = 0; i < res.data.list.length; i++) {
                        //      that.comment.push(res.data.list[i]);
                        // }
                      }else{

                      }
                              
                  });
                },
                isEmojiCharacter:function(substring) {  
                    for ( var i = 0; i < substring.length; i++) {  
                        var hs = substring.charCodeAt(i);  
                        if (0xd800 <= hs && hs <= 0xdbff) {  
                            if (substring.length > 1) {  
                                var ls = substring.charCodeAt(i + 1);  
                                var uc = ((hs - 0xd800) * 0x400) + (ls - 0xdc00) + 0x10000;  
                                if (0x1d000 <= uc && uc <= 0x1f77f) {  
                                    return true;  
                                }  
                            }  
                        } else if (substring.length > 1) {  
                            var ls = substring.charCodeAt(i + 1);  
                            if (ls == 0x20e3) {  
                                return true;  
                            }  
                        } else {  
                            if (0x2100 <= hs && hs <= 0x27ff) {  
                                return true;  
                            } else if (0x2B05 <= hs && hs <= 0x2b07) {  
                                return true;  
                            } else if (0x2934 <= hs && hs <= 0x2935) {  
                                return true;  
                            } else if (0x3297 <= hs && hs <= 0x3299) {  
                                return true;  
                            } else if (hs == 0xa9 || hs == 0xae || hs == 0x303d || hs == 0x3030  
                                    || hs == 0x2b55 || hs == 0x2b1c || hs == 0x2b1b  
                                    || hs == 0x2b50) {  
                                return true;  
                            }  
                        }  
                    }  
                }, 
                addComtent:function(){
                  var that=this;
                  if(this.commentContent==""){
                     showLayer("请输入观点"); 
                     return; 
                  }
                  if(this.isEmojiCharacter(this.commentContent)){
                     showLayer("不能输入表情"); 
                     return; 
                  }
                  ajaxFun("POST","/add_comment",{
                      unionid:this.unionid,
                      q_id:this.id,
                      comment:this.commentContent
                  },function(data){
                     var res=data;
                      if(res.code==1){
                          that.toggleView();
                          that.getComtent(that.from);
                          that.commentContent="";
                          showLayer(res.message);
                      }else{
                         showLayer(res.message);
                      }
                              
                  });
                },
                save:function(){
                  var that=this;
                  var answer="[";
                  var answer_select="[";
                  var that=this,obj=this.resObj.options,selects=this.resObj.selects;
                  if(obj.length>0){
                    for (var i = 0; i < obj.length; i++) {
                      answer+='{"id":'+obj[i].id+',"num":'+obj[i].guess_num+'},';
                      if(Number(obj[i].guess_num)<0){
                         showLayer("不能输入负数");  
                         return false;  
                      }
                      if(!obj[i].guess_num){
                         showLayer("请输入数字");  
                         return false;  
                      }
                      if(obj[i].guess_num<obj[i].mn||obj[i].guess_num>obj[i].mx){
                         showLayer("请输入"+obj[i].mn+"到"+obj[i].mx+"的数值");  
                         return false;  
                      }
                      if(obj[i].guess_num.toString().split(".").length>1&&obj[i].guess_num.toString().split(".")[1].length>4){
                        showLayer("小数位数不能大于5位数"); 
                        return false;
                      }
                    }
                    answer=answer.substring(0,answer.length-1);
                  }
                  answer+=']';
                   
                  if(selects.length>0){
                    for (var j = 0; j < selects.length; j++) {
                       for (var k = 0; k < selects[j].options.length; k++) {
                          if(selects[j].options[k].selected){
                            answer_select+='{"id":'+selects[j].id+',"answer":"'+selects[j].options[k].index+'"},';
                          }
                         
                       }
                    }
                    answer_select=answer_select.substring(0,answer_select.length-1);
                  }
                  answer_select+=']';
                  // console.log(answer_select)
                 if(answer_select=="]"){
                     showLayer("请选择答案"); 
                     return;
                 }
                  var arr=JSON.parse(answer_select);
                  if(arr.length!=selects.length){
                      showLayer("请选择答案"); 
                     return;
                  }

                  ajaxFun("POST","/save_guess_answer",{
                     q_id:this.id,
                     unionid:this.unionid,
                     answer:answer,
                     answer_select:answer_select
                  },function(data){
                      var res=data;
                      
                      if(res.code==1){
                         that.getDetail();
                         that.popFlag=true;
 
                      }else{
                        showLayer(res.message);
                      }
                              
                  });
                }
            }
        })
    </script>
</body>
</html>